<template>
  <el-drawer v-model="addDrawer" size="45%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <el-space direction="vertical" class="space-width100">
        <div v-if="route.path.includes('dataIntegrate') && form.qcOpinion">
          <el-form :model="form" :inline="true" label-width="140px">
            <el-form-item label="质检不通过原因" style="width: 100%">
              <el-input v-model="form.qcOpinion" type="textarea" :autosize="{ minRows: 4, maxRows: 6 }" resize="none"
                clearable></el-input>
            </el-form-item>
          </el-form>
        </div>
        <h2>
          <el-row justify="space-between">
            <span><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{ typeName }}</span></span>
            <el-button type="primary" @click="confirmClick" :disabled="drawerLoading"
              v-if="isShowSave">保存</el-button>
          </el-row>
        </h2>
      </el-space>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="140px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="测线编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入测线编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="微地貌测量工程编号" prop="geomorphySvyPrjId">
            <el-input v-model="form.geomorphySvyPrjId" placeholder="请输入微地貌测量工程编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="野外编号" prop="fieldId" style="width: 100%">
            <el-input v-model="form.fieldId" placeholder="请输入野外编号" clearable :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="50" resize="none"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="测线名称" prop="name" style="width: 100%">
            <el-input v-model="form.name" placeholder="请输入测线名称" clearable :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="50" resize="none"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="剖面线分析结果图图像文件编号" prop="profileAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.profileAiid" placeholder="请输入剖面线分析结果图图像文件编号" clearable maxlength="20"></el-input>
              <ImageUpload v-model="form.profileAiidName" @uploadImage="uploadSuccess('profileAiid', $event)"
                @delFile="deleteFile('profileAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="剖面线分析结果图原始文件编号" prop="profileArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.profileArwid" placeholder="请输入剖面线分析结果图原始文件编号" clearable maxlength="20"></el-input>
              <FileUpload v-model="form.profileArwidName" @uploadFile="uploadSuccess('profileArwid', $event)"
                @delFile="deleteFile('profileArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型照片文件编号" prop="photoAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.photoAiid" placeholder="请输入典型照片文件编号" clearable maxlength="20"></el-input>
              <ImageUpload v-model="form.photoAiidName" @uploadImage="uploadSuccess('photoAiid', $event)"
                @delFile="deleteFile('photoAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型照片原始文件编号" prop="photoArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.photoArwid" placeholder="请输入典型照片原始文件编号" clearable maxlength="20"></el-input>
              <FileUpload v-model="form.photoArwidName" @uploadFile="uploadSuccess('photoArwid', $event)"
                @delFile="deleteFile('photoArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="照片镜向" prop="photoViewingTo">
            <dict-select code="CVD-16-Direction" :value="form.photoViewingTo"
              @update="updateDict('photoViewingTo', $event)"></dict-select>
          </el-form-item>
          <el-form-item label="拍摄者" prop="photographer">
            <el-input v-model="form.photographer" placeholder="请输入拍摄者" clearable maxlength="20"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注-测量线描述及目的" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注-测量线描述及目的" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, uploadSuccess, deleteFile, updateDict, isShowSave } = useSpatialData()

const formRules = {
  id: [{ required: true, message: '请填写测线编号！', trigger: 'blur' }],
  geomorphySvyPrjId: [{ required: true, message: '请填写微地貌测量工程编号！', trigger: 'blur' }],
  fieldId: [{ required: true, message: '请填写野外编号！', trigger: 'blur' }]
}
</script>